import javax.swing.JComponent;

import java.awt.Color;

import java.awt.Graphics;

import java.awt.Graphics2D;

import java.awt.Rectangle;


public class CheckerBoardComponent extends JComponent

{
   
public void paintComponent(Graphics g)
   
{
     
 Graphics2D g2 = (Graphics2D) g;
     
 // your work here
      
for(int i=0;i<9;i++)
{
         
int m=i/3,n=i%3;
         
if(i%2==0){
 
 g2.setColor(Color.RED);
           
 g2.fillRect(n*50,m*50,50,50);
         }
         else 
{
            
g2.setColor(Color.WHITE);
            
g2.fillRect(n*50,m*50,50,50);
        
 }
      
}
   
}

}